package name.bingo.bing.pay.web.acid.service;

import com.google.common.base.Throwables;
import lombok.extern.slf4j.Slf4j;
import name.bingo.bing.pay.web.acid.dao.AcAccountDao;
import name.bingo.bing.pay.web.acid.model.AcAccount;
import name.bingo.bing.pay.web.acid.service.AcAccountWriteService;
import name.bingo.common.model.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 鍐欐湇鍔″疄鐜扮被
 *
 * @author [ your email ]
 * @date 2019-03-19 14:11:53
 * Created by CodeGen .
 */
@Slf4j
@Service
public class AcAccountWriteServiceImpl implements AcAccountWriteService {

    @Autowired
    private AcAccountDao acAccountDao;

    @Override
    public Response<Long> create(AcAccount acAccount) {
        try {
            acAccountDao.create(acAccount);
            return Response.ok(acAccount.getId());
        } catch (Exception e) {
            log.error("failed to create ac account, cause:{}", Throwables.getStackTraceAsString(e));
            return Response.fail("ac.account.create.fail");
        }
    }

    @Override
    public Response<Boolean> update(AcAccount acAccount) {
        try {
            return Response.ok(acAccountDao.update(acAccount));
        } catch (Exception e) {
            log.error("failed to update ac account, cause:{}", Throwables.getStackTraceAsString(e));
            return Response.fail("ac.account.update.fail");
        }
    }

}
